package com.uinfor.service.impl;

import com.uinfor.dao.IAccountDao;
import com.uinfor.service.IAccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @descripttion:
 * @Author: WZH
 * @Date :2021/2/5  17:29
 **/
@Service
public class AccountServiceImpl implements IAccountService {
    @Resource
    private IAccountDao iAccountDao;
    @Override
    public void decrease(Long userId, Double money) {
        System.out.println(userId);
        System.out.println(money);
        try {
            TimeUnit.SECONDS.sleep(20);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        Double moneyi =  iAccountDao.findCountByProduceId(userId);
        iAccountDao.decrease(userId,moneyi-money);
    }
}
